package com.lanqiao.gxnushop.service;

import com.lanqiao.gxnushop.entity.Promotions;
import com.lanqiao.gxnushop.mapper.PromotionsMapper;
import com.lanqiao.gxnushop.util.UUIdUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Schema(description ="促销活动表")
@Service
public class PromotionsService {
    @Autowired
    private PromotionsMapper promotionsMapper;

    /**添加促销活动*/
    public boolean addPromotions(Promotions promotions) {
        promotions.setPromotionId(UUIdUtil.getUserId());
        return promotionsMapper.add(promotions);
    }

    /**删除促销活动*/
    public boolean delete(String promotionId){
        return promotionsMapper.delete(promotionId);
    }

    /**修改促销活动*/
    public boolean update(Promotions promotions ){
        return promotionsMapper.update(promotions);
    }

    /**通过促销活动编号查找促销活动*/
    public Promotions select(String promotionId){
        return promotionsMapper.findById(promotionId);
    }

    @Schema(description ="查询所有促销活动")
    public ArrayList<Promotions> selectAll(){
        return promotionsMapper.selectAll();
    }

}
